﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    class Menu
    {
        ContentManager content;

        Texture2D t_comecar;
        Texture2D t_sair;

        Vector2 posicao;

        int ultimo_botao = 2;
        public int cont = 1;

        int cont_max = 0;
        int max = 20;

        public Menu(ContentManager content)
        {
            this.content = content;
        }

        public void Update(GameTime gameTime, KeyboardState teclado)
        {
            cont_max++;
            if (cont_max >= max) cont_max = max;
            if ((teclado.IsKeyDown(Keys.S) || teclado.IsKeyDown(Keys.Down)) && cont_max == max)
            {
                cont++;
                cont_max = 0;
            }
            if (teclado.IsKeyUp(Keys.W) && teclado.IsKeyUp(Keys.S) && teclado.IsKeyUp(Keys.Down) && teclado.IsKeyUp(Keys.Up)) cont_max = max;

            if ((teclado.IsKeyDown(Keys.W) || teclado.IsKeyDown(Keys.Up)) && cont_max == max)
            {
                cont++;
                cont_max = 0;
            }

            if (cont >= 3) cont = 1;
            if (cont <= 0) cont = ultimo_botao;
        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            posicao.X = 50;
            posicao.Y = 80;

            t_comecar = content.Load<Texture2D>("comecar1");
            if (cont == 1) t_comecar = content.Load<Texture2D>("comecar2");
            spriteBatch.Draw(t_comecar, posicao, Color.White);

            posicao.Y += 45;
            t_sair = content.Load<Texture2D>("sair1");
            if (cont == 2) t_sair = content.Load<Texture2D>("sair2");
            spriteBatch.Draw(t_sair, posicao, Color.White);
        }

    }

}
